﻿using KinonekoSoftware.CodariaDB.Documents.Templates;

namespace KinonekoSoftware.CodariaDB.Documents.DataParts
{
    public abstract class DataPart : DeltaObject
    {
        public static string GetIconName(DataPartType type)
        {
            try
            {
                var field = type.GetType().GetField(type.ToString());
                var attr = (Attribute.GetCustomAttribute(field, typeof(MetadataAttribute)) as MetadataAttribute);
                return attr?.Icon;
            }
            catch
            {
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public virtual DataPartType Type => DataPartType.Basic_Custom;
        
        /// <summary>
        /// 用来表示当前的部件属于哪个文档。
        /// </summary>
        public string DocumentID { get; init; }
    }
}